package Euclid;

public class StringVarType extends VarType {
	
	public String val;
	
	public StringVarType(String v, String f) {
		val = v;
		formula = f;
	}
	
	public StringVarType(String v) {
		val = v;
		formula = " ``\\text{" + v + "}\" ";
	}

	@Override
	public VarType add(VarType o) {
		if (o instanceof SymbVarType)
			return add(((SymbVarType)o).val);
		else if (o instanceof StringVarType)
			return new StringVarType(val + ((StringVarType)o).val);
		else
			return null;
	}

	@Override
	public String closeFormula() {
		return formula;
	}

	@Override
	public VarType div(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $\\div$ unsupported on type " + getClass());
	}
	
	@Override
	public VarType mod(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation \\textbf{mod} unsupported on type " + getClass());
	}

	@Override
	public VarType mult(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $\\times$ unsupported on type " + getClass());
	}

	@Override
	public VarType negate() {
		return new ErrorVarType("Operation $-$ unsupported on type " + getClass());
	}

	@Override
	public VarType not() {
		return new ErrorVarType("Operation $\\sim$ unsupported on type " + getClass());
	}

	@Override
	public VarType pow(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $x^y$ unsupported on type " + getClass());
	}

	@Override
	public VarType subtract(VarType o) {
		if (o instanceof ErrorVarType)
			return o;
		else
			return new ErrorVarType("Operation $-$ unsupported on type " + getClass());
	}
	
	public String toString()
	{
		return val;
	}

}
